Memory ballooning related memory allocation techniques for virtual machines

ABSTRACT

Systems and methods for encryption support for virtual machines. An example method may comprise maintaining, by a virtual machine running on a host computer system, a list of free memory pages, wherein each entry in the list references a set of memory pages that are contiguous in a guest address space; receiving, from a hypervisor of the host computer system, a request for guest memory to be made available to the hypervisor, wherein the request comprises a minimum size of guest memory requested and a maximum size of guest memory; and responsive to identifying, in the list of free memory pages, a set of contiguous guest memory pages that is greater than or equal to the minimum size of memory requested, and less than or equal to the maximum size of memory requested, releasing the set of contiguous guest memory pages to the hypervisor.

TECHNICAL FIELD

The present disclosure is generally related to virtualized computer systems, and more particularly, to memory ballooning related memory allocation techniques for virtual machines.

BACKGROUND

Virtualization herein shall refer to abstraction of some physical components into logical objects in order to allow running various software modules, for example, multiple operating systems, concurrently and in isolation from other software modules, on one or more interconnected physical computer systems. Virtualization allows, for example, consolidating multiple physical servers into one physical server running multiple virtual machines (also referred to herein as “guests” running on a host computer system) in order to improve the hardware utilization rate.

Virtualization may be achieved by running a software layer, often referred to as “hypervisor,” above the hardware and below the virtual machines. A hypervisor may run directly on the server hardware without an operating system beneath it or as an application running under a traditional operating system. A hypervisor may abstract the physical layer and present this abstraction to virtual machines to use, by providing interfaces between the underlying hardware and virtual devices of virtual machines.

Processor virtualization may be implemented by the hypervisor scheduling time slots on one or more physical processors for a virtual machine, rather than a virtual machine actually having a dedicated physical processor. Memory virtualization may be implemented by employing a page table (PT) which is a memory structure translating virtual memory addresses to physical memory addresses. Device and input/output (I/O) virtualization involves managing the routing of I/O requests between virtual devices and the shared physical hardware.

BRIEF DESCRIPTION OF THE DRAWINGS

The present disclosure is illustrated by way of examples, and not by way of limitation, and may be more fully understood with references to the following detailed description when considered in connection with the figures, in which:

FIG. 1 depicts a high-level block diagram of an example host computer system that performs encryption support for virtual machines, in accordance with one or more aspects of the present disclosure;

FIG. 2 depicts a block diagram illustrating components and modules of an example computer system, in accordance with one or more aspects of the present disclosure;

FIG. 3 depicts a flow diagram of an example method for inflating a memory balloon with a set of guest memory within a requested range, in accordance with one or more aspects of the present disclosure;

FIG. 4 depicts a block diagram of an example computer system in accordance with one or more aspects of the present disclosure;

FIG. 5 depicts a flow diagram of another example method for inflating a memory balloon with a set of guest memory within a requested range, in accordance with one or more aspects of the present disclosure; and

FIG. 6 depicts a block diagram of an illustrative computing device operating in accordance with the examples of the present disclosure.

DETAILED DESCRIPTION

Described herein are systems and methods for memory encryption for memory ballooning related memory allocation techniques for virtual machines.

Memory ballooning is a dynamic memory management technique for virtual machines (VMs) to allow the host system to reclaim unused memory from certain VMs and allocate the reclaimed memory to other VMs. In one example, a VM may, via a balloon driver, release memory that is no longer being used to the hypervisor. The released memory may be placed in a reserved memory pool called a balloon. The hypervisor may then re-allocate the released memory in the balloon to other VMs or for use by the hypervisor, host operating system, underlying hardware device, or a combination thereof. The released memory may then be removed from the balloon and returned to the VM at a later time.

In some systems, the hypervisor may request a size of guest memory (e.g., such as 2 MB, 8 MB, etc., or an amount of memory pages) to be made available to the hypervisor. “Memory page” herein shall refer to a contiguous portion of memory of a certain size. For example, a standard memory page may have the size of 4 KB, while a huge page may have the size of 2 MB or 1 GB. The VM may have memory pages that are free or can be freed and, thus, may search for such unused guest memory of the requested size. In some examples, the VM may allocate multiple portions of unused guest memory from different locations to satisfy the memory request. However, allocating portions from different locations may degrade performance of the VM due to memory fragmentation caused by breaking up contiguous partitions of guest memory, such as huge pages. In another example, the VM may break up a contiguous portion of unused guest memory until obtaining the requested size of guest memory. For example, responsive to a memory request of 2 MB, the VM may identify a 8 MB contiguous portion of unused guest memory, break up the portion into two 4 MB partitions, break up one of the 4 MB partitions into two 2 MB partitions, and release one of the two 2 MB partitions to the hypervisor. However, allocating large portions of contiguous memory depletes the amount of contiguous free memory available on the VM, which also may degrade performance of the VM due to memory fragmentation. Fragmentation of the guest memory may lead to performance degradation because the VM may not be able to satisfy large, contiguous memory allocation requests from applications. As such, it is desirable to prevent guest memory fragmentation from placing guest memory portions in a reserved memory pool and releasing host memory to the hypervisor (e.g., inflating a memory balloon).

Aspects of the present disclosure address the above and other deficiencies by implementing memory ballooning related memory allocation techniques for VMs. In particular, aspects of the present disclosure provide technology that allows a hypervisor to specify a range of requested guest memory, and allows a VM to inflate a memory balloon with any sized set of guest memory within the requested range. This allows the VM to minimize fragmentation when inflating the memory balloon increasing the likelihood that the VM may identify a portion of guest memory the exact size of the memory request, rather than allocating multiple portions of unused guest memory or breaking up a contiguous portion of guest memory. In an example, the VM may maintain a list of free (e.g., unused) memory pages. The list may be included in a data structure, such as, for example, a table. Each entry in the list may reference a set of memory pages that are contiguous in a guest address space. For example, each entry may be one or more contiguous standard memory pages, one or more contiguous huge pages, or any combination thereof. The VM may receive, from the hypervisor, a request for guest memory to be made available to the hypervisor. The request may include a range of the desired size of guest memory. For example, the request may include a minimum size of guest memory requested and a maximum size of guest memory. The VM may then identify a set of contiguous guest memory in the list of free memory pages that is that is greater than or equal to the minimum size of memory requested, and less than or equal to the maximum size of memory requested. The VM may then release the set of contiguous guest memory to the hypervisor. The released memory may be placed in a reserved memory pool (e.g., a balloon).

In an illustrative example, a VM may include entries of 2 MB, 2 MB, 5 MB, and 8 MB of free memory pages. The hypervisor may request a minimum of 4 MB of guest memory, and a maximum of 6 MB of guest memory. In response, the VM may query the list of free memory pages, and identify the 5 MB entry. The VM may then release memory pages associated with the 5 MB entry to the hypervisor. In conventional systems, the hypervisor may have allocated both 2 MB portions, or broken up the 8 MB portion into two 4 MB portions to allocate a 4 MB portion. Both scenarios would have increased memory fragmentation.

Various aspects of the above referenced methods and systems are described in details herein below by way of examples, rather than by way of limitation. The examples provided below discuss a virtualized computer system where memory movement may be initiated by aspects of a hypervisor, a host operating system, a virtual machine, or a combination thereof. In other examples, the memory movement may be performed in a non-virtualized computer system that is absent a hypervisor or other virtualization features discussed below.

FIG. 1 depicts an illustrative architecture of elements of a computer system 100, in accordance with an embodiment of the present disclosure. It should be noted that other architectures for computer system 100 are possible, and that the implementation of a computing device utilizing embodiments of the disclosure are not necessarily limited to the specific architecture depicted. Computer system 100 may be a single host machine or multiple host machines arranged in a cluster and may include a rackmount server, a workstation, a desktop computer, a notebook computer, a tablet computer, a mobile phone, a palm-sized computing device, a personal digital assistant (PDA), etc. In one example, computing device 100 may be a computing device implemented with x86 hardware. In another example, computing device 100 may be a computing device implemented with PowerPC®, SPARC®, or other hardware. In the example shown in FIG. 1 , computing device 100 may include virtual machines 110A-C, hypervisor 120, hardware devices 130, and a network 140.

Virtual machines 110A-C may execute guest executable code that uses an underlying emulation of the physical resources. The guest executable code may include a guest operating system, guest applications, guest device drivers, etc. Each of the virtual machines 110A-C may support hardware emulation, full virtualization, para-virtualization, operating system-level virtualization, or a combination thereof. Virtual machines 110A-C may have the same or different types of guest operating systems, such as Microsoft®, Windows®, Linux®, Solaris®, etc. Virtual machines 110A-C may execute guest operating systems 112A-C that manage guest memory 114A-C, memory balloons 115A-C, balloon drivers 116A-116C, and allocation components 118A-118C respectively.

Guest memory 114A-C may be any virtual memory, logical memory, physical memory, other portion of memory, or a combination thereof for storing, organizing, or accessing data. Guest memory 114A-C may represent the portion of memory that is designated by hypervisors 120 for use by one or more respective virtual machines 110A-C. Guest memory 114A-C may be managed by guest operating system 112A-C and may be segmented into guest pages. The guest pages may each include a contiguous or non-contiguous sequence of bytes or bits and may have a page size that is the same or different from a memory page size used by hypervisor 120. Each of the guest page sizes may be a fixed-size, such as a particular integer value (e.g., 4 KB, 2 MB) or may be a variable-size that varies within a range of integer values.

Hypervisor memory 126 (e.g., host memory) may be the same or similar to the guest memory but may be managed by hypervisor 120 instead of a guest operating system. Hypervisor memory 126 may be segmented into host pages, which may be in different states. The states may correspond to unallocated memory, memory allocated to guests, and memory allocated to hypervisor(s). The unallocated memory may be host memory pages and guest memory pages that have not yet been allocated by hypervisor memory 126 or were previously allocated by hypervisor 120 and have since been deallocated (e.g., freed) by hypervisor 120. The memory allocated to guests may be a portion of hypervisor memory 126 that has been allocated by hypervisor 120 to virtual machines 110A-C and corresponds to guest memory of virtual machine 114A-C. Other portions of hypervisor memory may be allocated for use by hypervisor 120, a host operating system, hardware device, other module, or a combination thereof.

Hypervisor 120 may also be known as a virtual machine monitor (VMM) and may provide virtual machines 110A-C with access to one or more features of the underlying hardware devices 130. In the example shown, hypervisor 120 may run directly on the hardware of computer system 100 (e.g., bare metal hypervisor). In other examples, hypervisor 120 may run on or within a host operating system (not shown). Hypervisor 120 may manage system resources, including access to hardware devices 130, and may manage execution of virtual machines 110A-C on a host machine. This includes provisioning resources of a physical central processing unit (“CPU”) to each virtual machine 110A-C running on the host machine. Provisioning the physical CPU resources may include associating one or more vCPUs with each virtual machine 110A-C. VCPUs may be provisioned by a core of the physical host CPU or a number of time slots reserved from one or more cores of the physical host CPU. VCPUs may be implemented by an execution thread that is scheduled to run on a physical host CPU. Software executing in virtual machines 110A-C may operate with reduced privileges such that hypervisor 120 retains control over resources. Hypervisor 120 retains selective control of the processor resources, physical memory, interrupt management, and input/output (“I/O”). In the example shown, hypervisor 120 may include memory manager 122.

Memory manager 122 may enable memory balloon operations by allowing hypervisor 120 to obtain and use memory pages from virtual machine 110A-C using, for example, memory balloon 115A-C, balloon driver 116A-C and/or allocation component 118A-C. Memory ballooning generally refers to a method of virtual memory management that allows hypervisor 120 to use memory allocated to any one of virtual machine 110A-C. Memory manager 122 may further track and manage mappings between guest memory 114A-C and hypervisor memory 126. For example, memory manager 122 may maintain a table, list or other structure that associates an address of guest memory 114A-C (e.g., a guest address) with an address of corresponding hypervisor memory 126 (e.g., a host address).

Balloon driver 116A-C may be a computer program installed on guest operating system 112A-C used to perform memory balloon operations involving guest memory 114A-C. In an example, hypervisor 120 uses balloon driver 116A-C to perform memory balloon operations involving guest memory 114A-C. For example, hypervisor 120 may use balloon driver 116A-C to inflate and deflate memory balloon 115A-C to reclaim or return guest memory 114A-C from/to virtual machine 110-C. Balloon driver 116A-C may be loaded into guest operating system 112A-C as a pseudo-device driver, and may have no external interface to guest operating system 112A-C. Accordingly, balloon driver 116A-C may not be known to guest operating system 112A-C, and hypervisor 120 may communicate with balloon driver 116A-C over a private communication channel.

Memory balloon 115A-C may be a reserved memory pool inaccessible to virtual machine 110A-C. For example, memory pages that have been placed in memory balloon 115A-C may be hidden from virtual machine 110A-C, inaccessible to virtual machine 110A-C, or protected from virtual machine 110A-C access. In one example, memory balloon 115A-C may refer to a classification or status of memory. For example, memory pages removed from guest memory 114A-C may be tagged with a status (e.g., “reserved,” “unavailable,” etc.) to indicate that corresponding memory pages may not be used by virtual machine 110A-C.

In an example, virtual machines 110A-C may have guest memory 114A-C that is free or can be freed. Memory ballooning allows hypervisor 120 to use memory allocated to virtual machine 110A-C. Hypervisor 120 may borrow memory allocated to virtual machine 110A-C by inflating memory balloon 115A-C. For example, memory manager 122 may send a memory request to balloon driver 116A-C over the private communication channel. The memory request may specify a target memory balloon 115A-C size or size range corresponding to an amount of memory sought by hypervisor 120. The balloon driver 115A-C may inflate memory balloon 115A in response to receiving a request for guest memory 114A-C from memory manager 122. In some embodiments, balloon driver 116A-C may inflate a memory balloon 115A-C by pinning memory pages from guest memory 114A-C in the memory balloon 115A-C. In some embodiments, balloon driver 116A-C inflates a memory balloon 115A by placing a number of memory pages from guest memory 114A-C in a reserved area of guest operating system 112A-C associated with memory balloon 115A-C. For example, the reserved area may be inaccessible to the virtual machine 110A-C and/or may prevent virtual machine 110A-C from performing operations involving memory pages pinned in memory balloon 115A-C.

Allocation component 118A-C may enable hypervisor 120 to specify a range of requested guest memory and may enable virtual machine 110A-C to inflate memory balloon 115A-C with a set of guest memory within the requested range. In particular, allocation component 118A-C may maintain a list of unused guest memory 114A-C. For example, allocation component 118A-C may maintain a list where each entry references a set of free memory pages contiguous in the guest address space. Each entry may be one or more contiguous standard memory pages, one or more contiguous huge pages, or any combination thereof. The list may be included in a data structure, such as, for example, a table.

Further, allocation component 118A-C may receive memory requests from hypervisor 120. Each memory request may include a range of desired guest memory. In particular, the request may include a minimum size of guest memory requested and a maximum size of guest memory. For example, the memory request may specify a size of guest memory requested (e.g., 2 KB, 5 MB, 1 GB, etc.), an amount of one or more types of memory pages requested (e.g., 12 standard memory pages, 4 huge memory pages, etc.) or any combination thereof. Responsive to the memory request, memory allocation component 118A-C may identify an entry from the list of a set of unused guest memory that is greater than or equal to the minimum size of memory requested, and less than or equal to the maximum size of memory requested. The allocation component 118A-C may then instruct the balloon driver 116A-C to inflate the balloon driver 115A-C with the guest memory from the identified entry. Allocation component 118A-C is discussed in more detail below in regards to FIG. 2 .

Hardware devices 130 may provide hardware resources and functionality for performing computing tasks. Hardware devices 130 may include one or more physical storage devices 132, one or more physical processing devices 134, other computing devices, or a combination thereof. One or more of hardware devices 130 may be split up into multiple separate devices or consolidated into one or more hardware devices. Some of the hardware device shown may be absent from hardware devices 130 and may instead be partially or completely emulated by executable code.

Physical storage devices 132 may include any data storage device that is capable of storing digital data and may include volatile or non-volatile data storage. Volatile data storage (e.g., non-persistent storage) may store data for any duration of time but may lose the data after a power cycle or loss of power. Non-volatile data storage (e.g., persistent storage) may store data for any duration of time and may retain the data beyond a power cycle or loss of power. In one example, physical storage devices 132 may be physical memory and may include volatile memory devices (e.g., random access memory (RAM)), non-volatile memory devices (e.g., flash memory, NVRAM), and/or other types of memory devices. In another example, physical storage devices 132 may include one or more mass storage devices, such as hard drives, solid state drives (SSD)), other data storage devices, or a combination thereof. In a further example, physical storage devices 132 may include a combination of one or more memory devices, one or more mass storage devices, other data storage devices, or a combination thereof, which may or may not be arranged in a cache hierarchy with multiple levels.

Physical processing devices 134 may include one or more processors that are capable of executing the computing tasks. Physical processing devices 134 may be a single core processor that is capable of executing one instruction at a time (e.g., single pipeline of instructions) or may be a multi-core processor that simultaneously executes multiple instructions. The instructions may encode arithmetic, logical, or I/O operations. In one example, physical processing devices 134 may be implemented as a single integrated circuit, two or more integrated circuits, or may be a component of a multi-chip module (e.g., in which individual microprocessor dies are included in a single integrated circuit package and hence share a single socket). A physical processing device may also be referred to as a central processing unit (“CPU”).

Network 140 may be a public network (e.g., the internet), a private network (e.g., a local area network (LAN), a wide area network (WAN)), or a combination thereof. In one example, network 140 may include a wired or a wireless infrastructure, which may be provided by one or more wireless communications systems, such as a wireless fidelity (WiFi) hotspot connected with the network 140 and/or a wireless carrier system that can be implemented using various data processing equipment, communication towers, etc.

FIG. 2 is a block diagram illustrating example components and modules of computer system 200, in accordance with one or more aspects of the present disclosure. Computer system 200 may comprise executable code that implements one or more of the components and modules and may be implemented within a hypervisor, a host operating system, a guest operating system, hardware firmware, or a combination thereof. In the example shown, computer system 200 may include allocation component 118, balloon driver 220 (which may be similar to balloon driver 116A-C), memory manager 122, and guest memory 230. Allocation component 118 may include free memory manager 212, search module 214, and instruction module 216. Guest memory 230 may be similar to guest memory 114A-C, and may include unreserved partition 232 and reserved partition 234. Unreserved partition 232 may include any portion of guest memory (e.g., guest memory pages) that is available for use by a VM (e.g., virtual machines 110A-C). Reserved partition 234 may include any portion of guest memory that is used to inflate a memory balloon (e.g., memory balloon 115A-C). For example, the memory pages in reserved partition 234 may be pinned in the memory balloon or placed in a reserved area of the guest operating system associated with the memory balloon (thus inaccessible to the VM).

Free memory manager 212 may maintain a list free (e.g., unused) memory pages in free memory table 225. Free memory table 225 may be any type of data structure used to store records of memory pages that are contiguous in a guest address space. Each entry in the free memory table 225 may reference a set of one or more contiguous standard memory pages, one or more contiguous huge pages, or any combination thereof. In some embodiments, free memory manager 212 may implement a buddy memory allocation technique and free memory pages may be maintained in a buddy allocated data structure. The buddy memory allocation technique is an algorithm that manages memory in power of two increments. In particular, guest memory may be broken up into blocks of pages where each block is a power of two number of pages. The exponent for the power of two sized block may be referred to as an order. For example, order 0 may be indicative of free page blocks of size 2⁰ (e.g., one memory page), order 1 may be indicative of free page blocks of size 2¹ (e.g., two memory pages), order 10 may be indicative of free page blocks of size 2¹⁰ (e.g., 1024 memory pages), etc. If a block of a desired size is not available, a larger block may be broken up in half, where one half may be used for allocation consideration and the other half is placed into free memory table 225 for a lower order. If the half used for consideration is too large, then the half may be further broken up into two more halves, and so on until the desired size is available. This allows allocation component 118 to divide the guest memory into partitions to satisfy a memory request.

Memory manager 122 may send a memory request to allocation component 118 for guest memory to be made available to the hypervisor. In an example, memory manager 122 may send the memory request in response to detecting a low amount of available hypervisor memory 126 by examining resources or performance counters. In another example, memory manager 122 may receive a notification from performance monitoring software indicating that a low hypervisor memory 126 condition exists. The memory request may specify a range of guest memory requested. For example, the memory request may include a minimum size of guest memory requested and a maximum size of guest memory requested. In some embodiments, the minimum size may be a standard memory page and the maximum size may be a huge page. In some embodiments, the minimum size may be a huge page and the maximum size may be multiple huge pages. Those skilled in the art would understand that any size may be used for the minimum size of guest memory requested and the maximum size of guest memory requested.

Search module 214 may search free memory table 225 for a set of guest memory that is within the range specified in the memory request. In an example, search component may begin the looking up the smallest available order, and determining whether the block size of that order will satisfy the memory request. Responsive to the block size not satisfying the memory request, search module 214 may move towards the next smallest available order. Once an entry is located that can satisfy the memory request (e.g., a block size between the minimum size of guest memory requested and a maximum size of guest memory requested), instruction module 216 may instruct the balloon driver 220 to mark the memory pages that are correlated to that entry as reserved (e.g., inflate the memory balloon), and release the memory pages to the memory manager 112. Free memory manager 212 may then update the free memory table 225 by removing the entry.

In an illustrative example, free memory table 225 may include entries of 4 KB, 1 MB, 2 MB, and 4 MB of free memory pages. The hypervisor may request a minimum of ½ MB of guest memory, and a maximum of 2 MB of guest memory. In response, search module 214 may query the free memory table 225 starting from the smallest available order, and identify the 4 KB entry. Free memory manager 212 may determine that the 4 KB entry will not satisfy the memory request, then move towards the next smallest available order, and identify the 1 MB entry. Since the 1 MB entry is greater than the minimum requested size of ½ MB, and less than the maximum requested size of 2 MB, instruction module 216 may then instruct balloon driver 220 to release the block of memory pages of the 2 MB entry to the hypervisor.

In some embodiments, free memory table 225 may not include an entry to satisfy a memory request. Accordingly, the search module 214 may identify an entry with a set of contiguous memory pages larger than the range of the memory request. The instruction module 216 may then break up the identified set until a portion of the set can satisfy the memory request, upon which that portion may be released to the hypervisor. The remainder of the set may be placed into free memory table 225 for a lower order. As such, a set of contiguous memory pages is not broken up unless it exceeds the maximum requested size.

In an illustrative example, free memory table 225 may include entries of 4 KB, 4 MB, and 8 MB of contiguous free memory pages. The hypervisor may request a minimum of ½ MB of guest memory, and a maximum of 2 MB of guest memory. In response, search module 214 may query the free memory table 225 starting from the smallest available order, and identify the 4 KB entry. Free memory manager 212 may determine that the 4 KB entry will not satisfy the memory request, then move towards the next smallest available order, and identify the 4 MB entry. Since the 4 MB block is greater than the maximum requested size of 2 MB, instruction module 216 may instruct memory manager 212 to break up the block into two blocks of 2 MB each, and update the free memory table 225. Search module 214 may then select one of 2 MB blocks, determine that the block is greater than the minimum requested size of ½ MB, and equal to the maximum requested size of 2 MB, and instruction module 216 may instruct balloon driver 220 to release this block of memory pages to the hypervisor.

In some embodiments, search module 214 may not identify any suitable entries in free memory table 225. Accordingly, instruction module 216 may instruct the VM to page-out (e.g., write memory pages to disk) a portion of guest memory to free some guest memory. Free memory manger 212 may then update free memory table 225 and search module 214 may initiate the search process again by querying free memory table 225 starting from the smallest available order. In some embodiments, free memory manager 212 may periodically analyze guest memory 230 to update the free memory table 225.

FIG. 3 depicts a flow diagram of an illustrative example of a method 300 for inflating a memory balloon with a set of guest memory within a requested range, in accordance with one or more aspects of the present disclosure. Method 300 and each of its individual functions, routines, subroutines, or operations may be performed by one or more processors of the computer device executing the method. In certain implementations, method 300 may be performed by a single processing thread. Alternatively, method 300 may be performed by two or more processing threads, each thread executing one or more individual functions, routines, subroutines, or operations of the method. In an illustrative example, the processing threads implementing method 300 may be synchronized (e.g., using semaphores, critical sections, and/or other thread synchronization mechanisms). Alternatively, the processes implementing method 300 may be executed asynchronously with respect to each other.

For simplicity of explanation, the methods of this disclosure are depicted and described as a series of acts. However, acts in accordance with this disclosure can occur in various orders and/or concurrently, and with other acts not presented and described herein. Furthermore, not all illustrated acts may be required to implement the methods in accordance with the disclosed subject matter. In addition, those skilled in the art will understand and appreciate that the methods could alternatively be represented as a series of interrelated states via a state diagram or events. Additionally, it should be appreciated that the methods disclosed in this specification are capable of being stored on an article of manufacture to facilitate transporting and transferring such methods to computing devices. The term “article of manufacture,” as used herein, is intended to encompass a computer program accessible from any computer-readable device or storage media. In one implementation, method 300 may be performed by a kernel of a hypervisor as shown in FIG. 1 or by an executable code of a host machine (e.g., host operating system or firmware), a virtual machine (e.g., guest operating system or virtual firmware), other executable code, or a combination thereof.

Method 300 may be performed by processing devices of a server device or a client device and may begin at block 302. At block 302, a virtual machine running on a host computer system may maintain a list of free memory pages. Each entry in the list may reference a set of memory pages that are contiguous in a guest address space. The list may be maintained in a buddy allocated data structure.

At block 304, the virtual machine may receive, from a hypervisor, a memory request for guest memory to be made available to the hypervisor. The memory request may include a minimum size of guest memory requested and a maximum size of guest memory. For example, the minimum size of memory requested may be a standard memory page and the maximum size of memory requested may be a huge page.

At block 306, responsive to identifying a set of contiguous guest memory pages in the list of free memory pages that is greater than or equal to the minimum size of memory requested, and less than or equal to the maximum size of memory requested, the virtual machine may release the set of contiguous guest memory pages to the hypervisor. For example, the virtual machine may identify the smallest set of contiguous guest memory pages that is greater than or equal to the minimum size of the memory requested and less than or equal to the maximum size of memory requested. The released set of contiguous guest memory pages may be placed in a reserved memory pool (e.g., a memory balloon).

In some embodiments, responsive to failing to identify, in the list of free memory pages, a set of contiguous guest memory pages that is greater than or equal to the minimum size of memory requested and less than or equal to the maximum size of memory requested, the virtual machine may satisfy the memory request by allocating a part of a portion of guest memory greater than the maximum size of memory requested (e.g., break apart a portion of guest memory). In some embodiments, responsive to failing to identify, in the list of free memory pages, a set of contiguous guest memory pages that is greater than or equal to the minimum size of memory requested and less than or equal to the maximum size of memory requested, the virtual machine may page-out a portion of guest memory. Responsive to completing the operations described herein above with references to block 306, the method may terminate.

FIG. 4 depicts a block diagram of a computer system 400 operating in accordance with one or more aspects of the present disclosure. Computer system 400 may be the same or similar to computer system 200 and computing device 100 and may include one or more processing devices and one or more memory devices. In the example shown, computer system 500 may include free memory manager 410, search module 420, and an instruction module 430.

Free memory manager 410 may maintain a list of free memory pages. Each entry in the list may reference a set of memory pages that are contiguous in a guest address space. The list may be maintained in a buddy allocated data structure.

Search module 420 may receive, from a hypervisor, a memory request for guest memory to be made available to the hypervisor. The memory request may include a minimum size of guest memory requested and a maximum size of guest memory. For example, the minimum size of memory requested may be a standard memory page and the maximum size of memory requested may be a huge page. Search module 420 may search the list of free memory pages for a set of memory pages to satisfy the memory request.

Responsive to search module 420 identifying a set of contiguous guest memory pages in the list of free memory pages that is greater than or equal to the minimum size of memory requested, and less than or equal to the maximum size of memory requested, instruction module 430 may release the set of contiguous guest memory pages to the hypervisor. For example, search module 420 may identify the smallest set of contiguous guest memory pages that is greater than or equal to the minimum size of the memory requested and less than or equal to the maximum size of memory requested. The released set of contiguous guest memory pages may be placed in a reserved memory pool (e.g., a memory balloon).

In some embodiments, responsive to failing to identify, in the list of free memory pages, a set of contiguous guest memory pages that is greater than or equal to the minimum size of memory requested and less than or equal to the maximum size of memory requested, the free memory manager 410 may satisfy the memory request by allocating a part of a portion of guest memory greater than the maximum size of memory requested (e.g., break apart a portion of guest memory). In some embodiments, responsive to failing to identify, in the list of free memory pages, a set of contiguous guest memory pages that is greater than or equal to the minimum size of memory requested and less than or equal to the maximum size of memory requested, the instruction module may page-out a portion of guest memory.

FIG. 5 depicts a flow diagram of one illustrative example of a method 500 for inflating a memory balloon with a set of guest memory within a requested range, in accordance with one or more aspects of the present disclosure. Method 500 may be similar to method 500 and may be performed in the same or a similar manner as described above in regards to method 500. Method 500 may be performed by processing devices of a server device or a client device and may begin at block 502.

At block 502, a processing device may maintain a list of free memory pages. Each entry in the list may reference a set of memory pages that are contiguous in a guest address space. The list may be maintained in a buddy allocated data structure.

At block 504, the processing device may receive, from a hypervisor, a memory request for guest memory to be made available to the hypervisor. The memory request may include a minimum size of guest memory requested and a maximum size of guest memory. For example, the minimum size of memory requested may be a standard memory page and the maximum size of memory requested may be a huge page.

At block 506, responsive to identifying a set of contiguous guest memory pages in the list of free memory pages that is greater than or equal to the minimum size of memory requested, and less than or equal to the maximum size of memory requested, the processing device may release the set of contiguous guest memory pages to the hypervisor. For example, the processing device may identify the smallest set of contiguous guest memory pages that is greater than or equal to the minimum size of the memory requested and less than or equal to the maximum size of memory requested. The released set of contiguous guest memory pages may be placed in a reserved memory pool (e.g., a memory balloon).

In some embodiments, responsive to failing to identify, in the list of free memory pages, a set of contiguous guest memory pages that is greater than or equal to the minimum size of memory requested and less than or equal to the maximum size of memory requested, the processing device may satisfy the memory request by allocating a part of a portion of guest memory greater than the maximum size of memory requested (e.g., break apart a portion of guest memory). In some embodiments, responsive to failing to identify, in the list of free memory pages, a set of contiguous guest memory pages that is greater than or equal to the minimum size of memory requested and less than or equal to the maximum size of memory requested, the processing device may page-out a portion of guest memory. Responsive to completing the operations described herein above with references to block 506, the method may terminate.

FIG. 6 depicts a block diagram of a computer system operating in accordance with one or more aspects of the present disclosure. In various illustrative examples, computer system 600 may correspond to computing device 100 of FIG. 1 or computer system 200 of FIG. 2 . The computer system may be included within a data center that supports virtualization. Virtualization within a data center results in a physical system being virtualized using virtual machines to consolidate the data center infrastructure and increase operational efficiencies. A virtual machine (VM) may be a program-based emulation of computer hardware. For example, the VM may operate based on computer architecture and functions of computer hardware resources associated with hard disks or other such memory. The VM may emulate a physical computing environment, but requests for a hard disk or memory may be managed by a virtualization layer of a computing device to translate these requests to the underlying physical computing hardware resources. This type of virtualization results in multiple VMs sharing physical resources.

In certain implementations, computer system 600 may be connected (e.g., via a network, such as a Local Area Network (LAN), an intranet, an extranet, or the Internet) to other computer systems. Computer system 600 may operate in the capacity of a server or a client computer in a client-server environment, or as a peer computer in a peer-to-peer or distributed network environment. Computer system 600 may be provided by a personal computer (PC), a tablet PC, a set-top box (STB), a Personal Digital Assistant (PDA), a cellular telephone, a web appliance, a server, a network router, switch or bridge, or any device capable of executing a set of instructions (sequential or otherwise) that specify actions to be taken by that device. Further, the term “computer” shall include any collection of computers that individually or jointly execute a set (or multiple sets) of instructions to perform any one or more of the methods described herein.

In a further aspect, the computer system 600 may include a processing device 602, a volatile memory 604 (e.g., random access memory (RAM)), a non-volatile memory 606 (e.g., read-only memory (ROM) or electrically-erasable programmable ROM (EEPROM)), and a data storage device 616, which may communicate with each other via a bus 608.

Processing device 602 may be provided by one or more processors such as a general purpose processor (such as, for example, a complex instruction set computing (CISC) microprocessor, a reduced instruction set computing (RISC) microprocessor, a very long instruction word (VLIW) microprocessor, a microprocessor implementing other types of instruction sets, or a microprocessor implementing a combination of types of instruction sets) or a specialized processor (such as, for example, an application specific integrated circuit (ASIC), a field programmable gate array (FPGA), a digital signal processor (DSP), or a network processor).

Computer system 600 may further include a network interface device 622. Computer system 600 also may include a video display unit 610 (e.g., an LCD), an alphanumeric input device 612 (e.g., a keyboard), a cursor control device 614 (e.g., a mouse), and a signal generation device 620.

Data storage device 616 may include a non-transitory computer-readable storage medium 624 on which may store instructions 626 encoding any one or more of the methods or functions described herein, including instructions for implementing methods 300 or 500 and for allocation component 122, and modules illustrated in FIGS. 1 and 2 .

Instructions 626 may also reside, completely or partially, within volatile memory 604 and/or within processing device 602 during execution thereof by computer system 600, hence, volatile memory 604 and processing device 602 may also constitute machine-readable storage media.

While computer-readable storage medium 624 is shown in the illustrative examples as a single medium, the term “computer-readable storage medium” shall include a single medium or multiple media (e.g., a centralized or distributed database, and/or associated caches and servers) that store the one or more sets of executable instructions. The term “computer-readable storage medium” shall also include any tangible medium that is capable of storing or encoding a set of instructions for execution by a computer that cause the computer to perform any one or more of the methods described herein. The term “computer-readable storage medium” shall include, but not be limited to, solid-state memories, optical media, and magnetic media.

The methods, components, and features described herein may be implemented by discrete hardware components or may be integrated in the functionality of other hardware components such as ASICS, FPGAs, DSPs or similar devices. In addition, the methods, components, and features may be implemented by firmware modules or functional circuitry within hardware devices. Further, the methods, components, and features may be implemented in any combination of hardware devices and computer program components, or in computer programs.

Unless specifically stated otherwise, terms such as “initiating,” “transmitting,” “receiving,” “analyzing,” or the like, refer to actions and processes performed or implemented by computer systems that manipulates and transforms data represented as physical (electronic) quantities within the computer system registers and memories into other data similarly represented as physical quantities within the computer system memories or registers or other such information storage, transmission or display devices. Also, the terms “first,” “second,” “third,” “fourth,” etc. as used herein are meant as labels to distinguish among different elements and may not have an ordinal meaning according to their numerical designation.

Examples described herein also relate to an apparatus for performing the methods described herein. This apparatus may be specially constructed for performing the methods described herein, or it may comprise a general purpose computer system selectively programmed by a computer program stored in the computer system. Such a computer program may be stored in a computer-readable tangible storage medium.

The methods and illustrative examples described herein are not inherently related to any particular computer or other apparatus. Various general purpose systems may be used in accordance with the teachings described herein, or it may prove convenient to construct more specialized apparatus to perform methods 300 or 500 and one or more of its individual functions, routines, subroutines, or operations. Examples of the structure for a variety of these systems are set forth in the description above.

The above description is intended to be illustrative, and not restrictive. Although the present disclosure has been described with references to specific illustrative examples and implementations, it will be recognized that the present disclosure is not limited to the examples and implementations described. The scope of the disclosure should be determined with reference to the following claims, along with the full scope of equivalents to which the claims are entitled. 

What is claimed is:
 1. A method comprising: maintaining, by a virtual machine running on a host computer system, a list of free memory pages, wherein each entry in the list references a set of memory pages that are contiguous in a guest address space; receiving, from a hypervisor of the host computer system, a request for guest memory to be made available to the hypervisor, wherein the request comprises a minimum size of guest memory requested and a maximum size of guest memory; and responsive to failing to identify, in the list of free memory pages, a set of contiguous guest memory pages that is greater than or equal to the minimum size of memory requested and less than or equal to the maximum size of memory requested, satisfying the request for guest memory by allocating a portion of guest memory greater than the maximum size of memory requested.
 2. The method of claim 1, further comprising: placing a released set of contiguous guest memory pages in a reserved memory pool.
 3. The method of claim 1, wherein releasing the set of contiguous guest memory pages to the hypervisor is performed by a balloon driver running on the virtual machine.
 4. The method of claim 1, wherein the minimum size of memory requested is a standard memory page and the maximum size of memory requested is a huge page.
 5. The method of claim 1, further comprising: identifying, in the list of free memory pages, the smallest set of contiguous guest memory pages that is greater than or equal to the minimum size of the memory requested and less than or equal to the maximum size of memory requested.
 6. The method of claim 1, further comprising: responsive to identifying, in the list of free memory pages, a set of contiguous guest memory pages that is greater than or equal to the minimum size of memory requested, and less than or equal to the maximum size of memory requested, releasing the set of contiguous guest memory pages to the hypervisor.
 7. The method of claim 1, further comprising: responsive to failing to identify, in the list of free memory pages, a set of contiguous guest memory pages that is greater than or equal to the minimum size of memory requested and less than or equal to the maximum size of memory requested, instructing the virtual machine to page-out a portion of guest memory.
 8. A system, comprising: a memory; a processing device operatively coupled to the memory, the processing device configured to: maintain a list of free memory pages, wherein each entry in the list references a set of memory pages that are contiguous in a guest address space; receive, from a hypervisor of a host computer system, a request for guest memory to be made available to the hypervisor, wherein the request comprises a minimum size of guest memory requested and a maximum size of guest memory; and responsive to failing to identify, in the list of free memory pages, a set of contiguous guest memory pages that is greater than or equal to the minimum size of memory requested and less than or equal to the maximum size of memory requested, satisfy the request for guest memory by allocating a portion of guest memory greater than the maximum size of memory requested.
 9. The system of claim 8, further comprising the processing device configured to: placing a released set of contiguous guest memory pages in a reserved memory pool.
 10. The system of claim 8, wherein releasing the set of contiguous guest memory pages to the hypervisor is performed by a balloon driver.
 11. The system of claim 8, wherein the minimum size of memory requested is a standard memory page and the maximum size of memory requested is a huge page.
 12. The system of claim 8, further comprising the processing device configured to: identifying, in the list of free memory pages, the smallest set of contiguous guest memory pages that is greater than or equal to the minimum size of the memory requested and less than or equal to the maximum size of memory requested.
 13. The system of claim 8, further comprising the processing device configured to: responsive to identifying, in the list of free memory pages, a set of contiguous guest memory pages that is greater than or equal to the minimum size of memory requested, and less than or equal to the maximum size of memory requested, releasing the set of contiguous guest memory pages to the hypervisor.
 14. The system of claim 8, further comprising the processing device configured to: responsive to failing to identify, in the list of free memory pages, a set of contiguous guest memory pages that is greater than or equal to the minimum size of memory requested and less than or equal to the maximum size of memory requested, instruct a virtual machine to page-out a portion of guest memory.
 15. A non-transitory machine-readable storage medium storing instructions that cause a processing device to: maintain a list of free memory pages, wherein each entry in the list references a set of memory pages that are contiguous in a guest address space; receive, from a hypervisor, a request for guest memory to be made available to the hypervisor, wherein the request comprises a minimum size of guest memory requested and a maximum size of guest memory; and responsive to failing to identify, in the list of free memory pages, a set of contiguous guest memory pages that is greater than or equal to the minimum size of memory requested and less than or equal to the maximum size of memory requested, satisfy the request for guest memory by allocating a portion of guest memory greater than the maximum size of memory requested.
 16. The non-transitory machine-readable storage medium of claim 15, further comprising the processing device configured to: placing a released set of contiguous guest memory pages in a reserved memory pool.
 17. The non-transitory machine-readable storage medium of claim 15, wherein releasing the set of contiguous guest memory pages to the hypervisor is performed by a balloon driver.
 18. The non-transitory machine-readable storage medium of claim 15, wherein the minimum size of memory requested is a standard memory page and the maximum size of memory requested is a huge page.
 19. The non-transitory machine-readable storage medium of claim 15, further comprising the processing device configured to: responsive to identifying, in the list of free memory pages, a set of contiguous guest memory pages that is greater than or equal to the minimum size of memory requested, and less than or equal to the maximum size of memory requested, release the set of contiguous guest memory pages to the hypervisor.
 20. The non-transitory machine-readable storage medium of claim 15, further comprising the processing device configured to: responsive to failing to identify, in the list of free memory pages, a set of contiguous guest memory pages that is greater than or equal to the minimum size of memory requested and less than or equal to the maximum size of memory requested, instruct a virtual machine to page-out a portion of guest memory. 